All Questions
20 questions
4votes
3answers
166views
Redouble each occurrence of char recursively, and add n
In following of this question, I would like to have a second review. The exercise is to write a recursive method that takes a String and a ...
3votes
2answers
1kviews
Counting the number of ways to decode a string
I am working on problem where I need to decode a string: A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' -> 1 'B' -> 2 ... '...
3votes
2answers
590views
Find the longest sub string of a word after concatenation of given words array
An Array of N words is given. Each word consists of small letters ('a'-'z'). Our goal is to concatenate the words in such a way as to obtain a single word with longest possible substring composed of ...
1vote
1answer
3kviews
All subsets of a String in java using recursion
I wrote this code for printing all sets of a String. It also prints the empty subset. Is this the right approach ...
1vote
1answer
499views
Reinterpreting a string, treating < as a backspace character
I've come up with a solution to this coding challenge using recursion. In summary, the input is a string where the < symbol represents a backspace (up to 1 ...
1vote
4answers
3kviews
Split a long string using recursive function
I have executed a program which reads long string and divide the string on basis of specified input. Well I am getting the correct output but would try it to be more efficient and readable. Opinions ...
0votes
1answer
633views
Permutations of string in Java [closed]
This is a program about finding all the permutations of an string. I want to be able to make it faster and more efficient like eliminating the recursion maybe. Please advise. What is intended is to ...
4votes
1answer
302views
String permutations
So I have tried the famous string permutation algorithm. Example for those who are not familiar with the algorithm: ABC -> ...
4votes
1answer
322views
String permutation iterative improvements?
I have written some code (below) which iterates over each character of a string and adds that character to every index of previous permutations. For example, in case of abc: b is added to every index ...
5votes
1answer
6kviews
Replacing characters in a Java string using iteration and recursion
I am new to the whole Data Structures thing and I want to get better at writing efficient code. So, I have been practicing some problem sets. The questions is - Replace characters in a string using ...
3votes
3answers
6kviews
Recursively moving every lowercase 'x' in a string to the end
Given a string, compute recursively a new string where all the lowercase 'x' chars have been moved to the end of the string. ...
3votes
1answer
570views
Counting occurrences of "hi" in a string, except where followed by "x"
I already solved this one from CodingBat, but I'm unsatisfied with my solution and I feel I could have made it much shorter. Most of the other recursion tasks could be solved by a one line conditional ...
3votes
2answers
3kviews
Non-Contiguous Substrings
Problem: A non-contiguous substring of string \$s\$ is a sequence of \$k \geq 0\$ characters in \$s\$, in the order in which they occur in \$s\$. For instance, the set of all non-contiguous ...
10votes
2answers
449views
You need to diversify your strings
Challenge: Write a program which prints all the permutations of a string in alphabetical order. Specifications: Your program should accept a file as its first argument. The file contains input ...
4votes
3answers
5kviews
Reversing strings using recursion
I'm trying to solve exercises where I am required to use recursion. I wrote this: ...